{% extends "settings/base.html" %}

{% block container-right %}
    <h2 class="heading">GitHub关联账户</h2>
    {% if thirdpartyUser %}
    <ul class="relative-accounts">
      <li>
        <i class="icon-github"></i>{{ thirdpartyUser.tp_username }}
        <a href="#" id="id_github_relieve" class="disconnect">解除绑定</a>
      </li>
    </ul>
    {% else %}
    <a target="_blank" href="https://github.com/login/oauth/authorize?client_id=63bbd038b8591356a841&redirect_uri=https://gitshell.com/login/oauth/github/apply/" class="btn btn-success"><i class="icon-github"></i>关联 GitHub 账户</a>
    {% endif %}
{% endblock %}

{% block js %}
<script>
/*global jQuery, window */
$(function(){
    $('#id_github_relieve').click(function(){
        $.post('/login/oauth/github/relieve/', {csrfmiddlewaretoken: '{{ csrf_token }}'}, function(json){
            if(json.code == 200) {
                    window.location.href = window.location.href;
            }
        });
    });
});
</script>
{% endblock %}
